/*
仓库界面
*/
window._MG = {
    _LEFTNODE:null,
    _CURRENTSENCE:null,//当前场景
    _PAGESIZE:16,
    _PAGE:0,
    _CURRENTGOODSTYPE:null,
    _DEFAULTGOODSTYPE:'fightItem',
    _CURRENTLABEL:null,
    _CURRENTPARAM:null,
    _TABCONFIG:{
        'fightItem':'prop01',
        'equipItem':'equipment01',
        'skillItem':'skill01',
        'materialItem':'material01',
        'specilItem':'special01',
        'teamSkill':'teamskill01',
    },

    initUi:function(parentNode,param){

        if(!param){
            return ;
        }

        _MG._CURRENTPARAM = param;

        if(param.goodsType){
            _MG._CURRENTGOODSTYPE=param.goodsType;
        }else{
            _MG._CURRENTGOODSTYPE=_MG._DEFAULTGOODSTYPE;
        }
        _MG._CURRENTSENCE = param.sence;
        var uiObj = _GRM.getNodeObj('goodsLabel');
        var mainLabel = uiObj.node;
        var leftLabel = mainLabel.getChildByName('leftLabel');
        _MG._CURRENTLABEL = mainLabel;
        _MG._PAGE = 0;

        _MG.initLeftNode(leftLabel);

        if(uiObj.isnew){
            _MG.hideAll(mainLabel);
            _MG.initButton(mainLabel);
        }

        _MG.refreshPage(mainLabel);

        parentNode.addChild(mainLabel);

    },

    refreshEnableTips:function(cellNode,goodsInfo){

        var enableLvNode = cellNode.getChildByName('enableStatus');

        var role = _MRDL.getCurrentRole();

        if(!goodsInfo||!role){
            enableLvNode.active = false;
            return;
        }
        
        
        var bfNode = enableLvNode.getChildByName('jb_bf');
        var spNode = enableLvNode.getChildByName('jb_sp');
        var wmNode = enableLvNode.getChildByName('jb_wm');

        if(
            goodsInfo.objtype=="equip"
            ||goodsInfo.objtype=="skillbd"
            ||goodsInfo.objtype=="skill"
        ){
            enableLvNode.active = true;
            var npcxw = role.xw;
            var sourcexw = null;
            var sourcexwnmb = 0;
            if(goodsInfo.objtype=="equip"){
                sourcexw=goodsInfo.xw;
            }else if(goodsInfo.objtype=="skillbd"){
                sourcexw = _SKILLBD[goodsInfo.type].xw;
            }else{
                sourcexw = _SKILL[goodsInfo.type].xw;
            }
            if(sourcexw){
                var allflag = true;
                var singleflag = false;
                for(var key in sourcexw){
                    sourcexwnmb++;
                    if(!npcxw[key]&&npcxw[key]!=0){
                        allflag=false;
                    }else{
                        singleflag=true;
                    }
                }
            }

            if(
                goodsInfo.objtype=="equip"
            ){

                var rolejob = _NPC[role.npctype]?_NPC[role.npctype].job:null;
                var rolejobequip = _JOB[rolejob]?_JOB[rolejob].equipType:null;
                var equiptype = _EQUIP[goodsInfo.type]?_EQUIP[goodsInfo.type].type:null;

                if(_CU.isContain(rolejobequip,equiptype)){
                    if(!singleflag){
                        bfNode.active = true;
                        spNode.active = false;
                        wmNode.active = false;
                        return ;
                    }else{
                        if(allflag){
                            bfNode.active = false;
                            if(sourcexwnmb>=5){
                                wmNode.active = true;
                                spNode.active = false;
                            }else{
                                wmNode.active = false;
                                spNode.active = true;
                            }
                                
                            return ;
                        }else{
                            bfNode.active = false;
                            spNode.active = true;
                            wmNode.active = false;
                            return ;
                        }
                    }
                }
            }else{
                /*
                if(!allflag){
                    bfNode.active = true;
                    spNode.active = false;
                    wmNode.active = false;
                    return ;
                }else{
                    bfNode.active = false;
                    spNode.active = true;
                    wmNode.active = false;
                    return ;
                }*/
               var canWear = _SKILLHEPLER.canWear(role,goodsInfo.type);
                if(!canWear.flag){
                    bfNode.active = false;
                    spNode.active = false;
                    wmNode.active = false;
                    return ;
                }else{
                    bfNode.active = false;
                    spNode.active = true;
                    wmNode.active = false;
                    return;
                }
            }


        }

        enableLvNode.active = false;
    },

    refreshCell:function(cellNode,goodsInfo){

        var goodsInfoImg =goodsInfo? _IOF.getGoodsImg(goodsInfo):null;
        var goodsInfoColor = goodsInfo?_IOF.getGoodsColor(goodsInfo):null;
        var goodsInfoFtype = goodsInfo?_IOF.getGoodsFtype(goodsInfo):null;

        var nameNode = cellNode.getChildByName('nmb');
        var imgNode = cellNode.getChildByName('img');
        var lockNode = cellNode.getChildByName('img_lock');
        var starNode = cellNode.getChildByName('xinxin');
        var nmbNode = cellNode.getChildByName('numbei');
        var lvNode = cellNode.getChildByName('forging');
        var ftypeNode = cellNode.getChildByName('wuxin');
        //var kongNode = cellNode.getChildByName('kong');

        var otherNode1 = cellNode.getChildByName('goods_guan');
        var otherNode2 = cellNode.getChildByName('guan_wupin');
        var otherNode3 = cellNode.getChildByName('bg_wupingkuan_top');

        _MG.refreshEnableTips(cellNode,goodsInfo);

        cellNode.color = new cc.color("#161410");
        nameNode.active = false;
        imgNode.active = false;
        lockNode.active = false;
        starNode.active = false;
        nmbNode.active = false;
        lvNode.active = false;
        ftypeNode.active = false;
        otherNode1.active = false;
        otherNode2.active = false;
        otherNode3.active = false;
        //kongNode.active = false;

        if(goodsInfo==null){
            return;
        }

        otherNode1.active = true;
        otherNode2.active = true;
        otherNode3.active = true;
        imgNode.active = true;
        nameNode.active = true;
        nameNode.getComponent(cc.Label).string = goodsInfo.type;
        if(goodsInfo.isLock){
            lockNode.active = true;
        }

        imgNode.getComponent(cc.Sprite).spriteFrame = _GRM.getEquipFrame(goodsInfoImg);
        cellNode.color = new cc.color(goodsInfoColor);
        if(goodsInfo.nmb){
            nmbNode.active=true;
            nmbNode.getComponent(cc.Label).string = goodsInfo.nmb>999?'999+':goodsInfo.nmb;
        }

        if(goodsInfoFtype){
            ftypeNode.active = true;
            ftypeNode.getChildByName('label').getComponent(cc.Label).string = goodsInfoFtype.ftype;
            ftypeNode.color = new cc.color(goodsInfoFtype.color);
        }

        if(goodsInfo.objtype=="equip"){
            var goodsConfig = _EQUIP[goodsInfo.type];
            
            var goodslv = goodsInfo.dzlevel;
            if(goodslv>0){
                lvNode.active = true;
                lvNode.getComponent(cc.Label).string = "+"+goodslv;
            }

            //传家宝标记
            if(goodsConfig.iszs){
                starNode.active = true;
            }
            
            /*
            if(goodsInfo.stone&&goodsInfo.stone.length>0){
                kongNode.active = true;
                for(var i=0;i<kongNode.getChildren().length;i++){
                    if(goodsInfo.stone[i]){
                        kongNode.getChildren()[i].active = true;
                        kongNode.getChildren()[i].color = new cc.color(_CS.ftype[goodsInfo.stone[i].ftype].color);
                    }else{
                        kongNode.getChildren()[i].active = false;
                    }
                }
            }
            */
            
        }else if(goodsInfo.objtype=="fightitem"){

    
        }else if(goodsInfo.objtype=="skill"||goodsInfo.objtype=="skillbd"){
            
            //var goodsConfig = _SKILL[goodsInfo.type]?_SKILL[goodsInfo.type]:_SKILLBD[goodsInfo.type];
            
            if(_SKILLHEPLER.isZhuanshu(goodsInfo.type)){
                starNode.active = true;
            }
        }else if(goodsInfo.objtype=="material"){
            
        }else if(goodsInfo.objtype=="makebook"){
            if(_MAKE[goodsInfo.type])
            nameNode.getComponent(cc.Label).string = _MAKE[goodsInfo.type].item;
        }

    },

    //获取装镶嵌等级
    getLvOfEquip:function(goodsInfo){
        if(!goodsInfo||!goodsInfo.stone){
            return 0;
        }

        var lv = 0;
        for(var i=0;i<goodsInfo.stone.length;i++){
            if(goodsInfo.stone[i].value){
                lv++;
            }
        }
        return lv;
    },

    //整理仓库
    resetGoods:function(node){

        var source = window.gameData[_MG._CURRENTGOODSTYPE];
        var cacheMap = null;
        var target = null;
        if(_MG._CURRENTGOODSTYPE=="fightItem"){
            cacheMap={'SS':[],'S':[],'A':[],'B':[],'C':[]};
            target=[];
            for(var i=0;i<source.length;i++){
                var type = source[i].type;
                var conf = _FIGHTITEM[type];
                if(!cacheMap[conf.qua]){
                    cacheMap[conf.qua]={};
                }
                if(!cacheMap[conf.qua][conf.skilltype]){
                    cacheMap[conf.qua][conf.skilltype]=[];
                }
                cacheMap[conf.qua][conf.skilltype].push(source[i]);
            }
            for(var key1 in cacheMap){
                for(var key in cacheMap[key1]){
                    for(var i=0;i<cacheMap[key1][key].length;i++){
                        target.push(cacheMap[key1][key][i]);
                    }
                }
            }
        }else if(_MG._CURRENTGOODSTYPE=="equipItem"){

            cacheMap={};
            var orderarr = [];
            target=[];
            for(var i=0;i<source.length;i++){
                var type = source[i].type;
                var conf = _EQUIP[type];
                if(!cacheMap[type]){
                    cacheMap[type]={'SS':[],'S':[],'A':[],'B':[],'C':[]};
                    orderarr.push(type);
                }
                if(!cacheMap[type][conf.qua]){
                    cacheMap[type][conf.qua]=[];
                }
                cacheMap[type][conf.qua].push(source[i]);
            }

            orderarr.sort((a,b)=>{
                var confa = _EQUIP[a];
                var confb = _EQUIP[b];
                return confb.lv-confa.lv;
            });

            for(var i=0;i<orderarr.length;i++){
                var etype = orderarr[i];
                for(var key in cacheMap[etype]){
                    for(var j=0;j<cacheMap[etype][key].length;j++){
                        target.push(cacheMap[etype][key][j]);
                    }
                }
            }

        }else if(_MG._CURRENTGOODSTYPE=="materialItem"){

            cacheMap={'金':[],'木':[],'水':[],'火':[],'土':[],'无':[]};
            target=[];
            for(var i=0;i<source.length;i++){
                var type = source[i].type;
                var conf = _M[type];
                
                if(conf){
                    var confftype = conf.ftype?conf.ftype:'无';
                    var confqua = conf.qua;
                    if(!cacheMap[confftype]){
                        cacheMap[confftype]={'SS':[],'S':[],'A':[],'B':[],'C':[]};
                    }
                    if(!cacheMap[confftype][confqua]){
                        cacheMap[confftype][confqua]=[];
                    }
                    cacheMap[confftype][confqua].push(source[i]);
                }
            }

            for(var key1 in cacheMap){
                for(var key in cacheMap[key1]){
                    for(var i=0;i<cacheMap[key1][key].length;i++){
                        target.push(cacheMap[key1][key][i]);
                    }
                }
            }
            

        }else if(_MG._CURRENTGOODSTYPE=="skillItem"){

            cacheMap={'金':[],'木':[],'水':[],'火':[],'土':[],'无':[]};
            target=[];
            for(var i=0;i<source.length;i++){
                var type = source[i].type;
                var isbd = "1";
                var conf = _SKILL[type];
                if(!conf){
                    isbd = "0";
                    conf = _SKILLBD[type];
                }
                if(conf){
                    var confftype = conf.ftype?conf.ftype:'无';
                    if(!cacheMap[confftype][isbd]){
                        cacheMap[confftype][isbd]={'1':[],'0':[]};
                    }
                    if(!cacheMap[confftype][isbd][conf.level]){
                        cacheMap[confftype][isbd][conf.level]=[];
                    }
                    cacheMap[confftype][isbd][conf.level].push(source[i]);
                }
            }
            for(var key2 in cacheMap){
                for(var key1 in cacheMap[key2]){
                    for(var key in cacheMap[key2][key1]){
                        for(var i=0;i<cacheMap[key2][key1][key].length;i++){
                            target.push(cacheMap[key2][key1][key][i]);
                        }
                    }
                }
            }

        }else if(_MG._CURRENTGOODSTYPE=="specilItem"){

            cacheMap={};
            target=[];
            var orderarr = [];
            for(var i=0;i<source.length;i++){
                var type = source[i].type;
                cacheMap[type]=source[i];
                orderarr.push(type);
            }

            orderarr.sort((a,b)=>{
                if(
                    _MAKE[a]
                    &&_MAKE[b]
                    &&_EQUIP[_MAKE[a].item]
                    &&_EQUIP[_MAKE[b].item]
                ){
                    var confa = _EQUIP[_MAKE[a].item];
                    var confb = _EQUIP[_MAKE[b].item];
                    return confb.lv-confa.lv;
                }

                return 0;
            });

            for(var i=0;i<orderarr.length;i++){
                target.push(cacheMap[orderarr[i]]);
            }

        }else if(_MG._CURRENTGOODSTYPE=="teamSkill"){
            cacheMap={'SS':[],'S':[],'A':[],'B':[],'C':[]};
            target=[];
            for(var i=0;i<source.length;i++){
                var type = source[i].type;
                var conf = _SKILLTEAM[type];
                cacheMap[conf.qua].push(source[i]);
            }
            for(var key in cacheMap){
                for(var i=0;i<cacheMap[key].length;i++){
                    target.push(cacheMap[key][i]);
                }
            }
        }
        if(target&&target.length>0)
            window.gameData[_MG._CURRENTGOODSTYPE]=target;
        _MG._PAGE=0;
        _MG.refreshPage(node);
    },

    getCurrentGoodsInfoArr:function(){
        
        return window.gameData[_MG._CURRENTGOODSTYPE];
    },

    hideAll:function(mainLabel){
        var goods = mainLabel.getChildByName('rightLabel')
                   .getChildByName('background').getChildByName('goods').getChildren();
        for(var i=0;i<goods.length;i++){
            _MG.refreshCell(goods[i],null);
        }
    },

    //刷新当前页
    refreshPage:function(mainLabel){
        var goods = mainLabel.getChildByName('rightLabel')
                   .getChildByName('background').getChildByName('goods').getChildren();
        var pageNode = mainLabel.getChildByName('rightLabel').getChildByName('background').getChildByName('page');
        var tabNode = mainLabel.getChildByName('rightLabel').getChildByName('background').getChildByName('tab');

        for(var key in _MG._TABCONFIG){
            if(_MG._CURRENTGOODSTYPE==key){
                tabNode.getChildByName(_MG._TABCONFIG[key]).active = true;
            }else{
                tabNode.getChildByName(_MG._TABCONFIG[key]).active = false;
            }
        }

        pageNode.getChildByName('label').getComponent(cc.Label).string = '第'+(_MG._PAGE+1)+'页';

        var goodsInfoArr = _MG.getCurrentGoodsInfoArr();
        var start = _MG._PAGE*_MG._PAGESIZE;
        var end = (_MG._PAGE+1)*_MG._PAGESIZE;
        var startIndex = 0;
        for(var i=start;i<end;i++){
            if(goodsInfoArr&&goodsInfoArr[i]){
                _MG.refreshCell(goods[startIndex],goodsInfoArr[i]);
            }else{
                _MG.refreshCell(goods[startIndex],null);
            }
            startIndex++;
        }
    },

    initButton:function(mainLabel){

        var btnParent = mainLabel.getChildByName('rightLabel').getChildByName('btn');
        var pageNode = mainLabel.getChildByName('rightLabel').getChildByName('background').getChildByName('page');
        var tabNode = mainLabel.getChildByName('rightLabel').getChildByName('background').getChildByName('tab');
        var goodsNode = mainLabel.getChildByName('rightLabel').getChildByName('background').getChildByName('goods').getChildren();


        var btnClode = btnParent.getChildByName('close');
        var btnSell = btnParent.getChildByName('sell');
        var btnClear = btnParent.getChildByName('organize');

        var btnLeft = pageNode.getChildByName('btnLeft');
        var btnRight = pageNode.getChildByName('btnRight');
        var first = pageNode.getChildByName('first');
        var tail = pageNode.getChildByName('tail');

        var prop = tabNode.getChildByName('prop');
        var equipment = tabNode.getChildByName('equipment');
        var material = tabNode.getChildByName('material');
        var special = tabNode.getChildByName('special');
        var skill = tabNode.getChildByName('skill');
        var teamskill = tabNode.getChildByName('teamskill');

        
        //关闭按钮
        btnClode.on(cc.Node.EventType.TOUCH_START, function(){
            _MG.closeMG();
        }, mainLabel);

        btnSell.on(cc.Node.EventType.TOUCH_START, function(){
            //console.log('出售全部');
            _CHOICEMANAGER.showChoice(_MAP.node,'selloutall',_MG._CURRENTGOODSTYPE);
        }, mainLabel);

        btnClear.on(cc.Node.EventType.TOUCH_START, function(){
            //console.log('清理');
            _MG.resetGoods(mainLabel);
        }, mainLabel);

        btnLeft.on(cc.Node.EventType.TOUCH_START, function(){
            //console.log('左');
            _MG.turnPage(this,-1);
        }, mainLabel);

        btnRight.on(cc.Node.EventType.TOUCH_START, function(){
            //console.log('右');
            _MG.turnPage(this,1);
        }, mainLabel);

        first.on(cc.Node.EventType.TOUCH_START, function(){
            //console.log('首页');
            _MG._PAGE=0;
            _MG.refreshPage(this);
        }, mainLabel);

        tail.on(cc.Node.EventType.TOUCH_START, function(){
            //console.log('尾页');
            _MG._PAGE=_MG.getTotalPage()-1;
            if(_MG._PAGE<0){
                _MG._PAGE=0;
            }
            _MG.refreshPage(this);
        }, mainLabel);

        prop.on(cc.Node.EventType.TOUCH_START, function(){
            //console.log('道具');
            _MG._CURRENTGOODSTYPE='fightItem';
            _MG._PAGE = 0;
            _MG.refreshPage(this);
        }, mainLabel);
        
        equipment.on(cc.Node.EventType.TOUCH_START, function(){
            //console.log('装备');
            _MG._CURRENTGOODSTYPE='equipItem';
            _MG._PAGE = 0;
            _MG.refreshPage(this);
        }, mainLabel);

        material.on(cc.Node.EventType.TOUCH_START, function(){
            //console.log('材料');
            _MG._CURRENTGOODSTYPE='materialItem';
            _MG._PAGE = 0;
            _MG.refreshPage(this);
        }, mainLabel);

        special.on(cc.Node.EventType.TOUCH_START, function(){
            //console.log('特殊');
            _MG._CURRENTGOODSTYPE='specilItem';
            _MG._PAGE = 0;
            _MG.refreshPage(this);
        }, mainLabel);

        skill.on(cc.Node.EventType.TOUCH_START, function(){
            //console.log('技能');
            _MG._CURRENTGOODSTYPE='skillItem';
            _MG._PAGE = 0;
            _MG.refreshPage(this);
        }, mainLabel);

        teamskill.on(cc.Node.EventType.TOUCH_START, function(){
            //console.log('军团技能');
            _MG._CURRENTGOODSTYPE='teamSkill';
            _MG._PAGE = 0;
            _MG.refreshPage(this);
        }, mainLabel);

        for(var i=0;i<goodsNode.length;i++){
            var goodsbtn = goodsNode[i];
            goodsbtn.goodsIndex = i;
            goodsbtn.on(cc.Node.EventType.TOUCH_START, function(){
                //console.log('格子:'+this.goodsIndex);
                var goodsInfoArr = _MG.getCurrentGoodsInfoArr();

                var realIndex = _MG._PAGE*_MG._PAGESIZE+this.goodsIndex;

                if(goodsInfoArr[realIndex]){

                    var tempGoodsInfo = goodsInfoArr[realIndex];

                    //console.log(tempGoodsInfo);

                    if(
                        _MG._CURRENTSENCE==_STYPE._GOODSSENCE
                        ||_MG._CURRENTSENCE==_STYPE._SHOPSENCE
                    ){
                        _MGD.showGoodsUi(_MAP.node,
                                        tempGoodsInfo,
                                        {
                                            sence:_MG._CURRENTSENCE,
                                            pos:_MGD._POSGOODS,
                                            goodsIndex:realIndex,
                                            arr:goodsInfoArr
                                        });
                    }else if(_MG._CURRENTSENCE==_STYPE._INLAYSENCE){

                        //if(tempGoodsInfo.objtype=="equip"){
                            //_MINLAY.setEquip(tempGoodsInfo);
                        //}else 
                        if(tempGoodsInfo.objtype=="material"||tempGoodsInfo.objtype=="equip"){
                            //_MINLAY.addStone(tempGoodsInfo,this.goodsIndex,goodsInfoArr);

                            _MGD.showGoodsUi(_MAP.node,
                                tempGoodsInfo,
                                {
                                    sence:_MG._CURRENTSENCE,
                                    pos:_MGD._POSGOODS,
                                    goodsIndex:realIndex,
                                    arr:goodsInfoArr
                                });

                        }else {
                            _TIPS.showMessage('此物品无法用于镶嵌!',0);
                        }

                    }else if(_MG._CURRENTSENCE==_STYPE._XQSENCE){

                        if(tempGoodsInfo.objtype=="equip"){
                            _MXQ.setEquip(tempGoodsInfo);
                        }else if(
                            tempGoodsInfo.objtype=="fightitem"
                            &&_FIGHTITEM[tempGoodsInfo.type].skilltype=="bosspart"
                        ){
                            _MXQ.setXq(tempGoodsInfo,realIndex,goodsInfoArr);
                        }else{
                            console.log(tempGoodsInfo);
                            _TIPS.showMessage('此物品无法用于镶嵌!');
                        }

                    }else if(_MG._CURRENTSENCE==_STYPE._MAKESENCE){

                        /*
                        if(tempGoodsInfo.objtype=="makebook"){
                            _MFORGIN.setBook(tempGoodsInfo.type);
                        }else if(tempGoodsInfo.objtype=="equip"){
                            _MFORGIN.setEquip(tempGoodsInfo,this.goodsIndex);
                        }else if(tempGoodsInfo.objtype=="material"){
                            _MFORGIN.setM(tempGoodsInfo,this.goodsIndex);
                        }else {
                            _TIPS.showMessage('此物品无法打造!',0);
                        }*/

                        if(tempGoodsInfo.objtype=="makebook"){
                            _MFORGIN.setBook(tempGoodsInfo.type);
                        }else if(tempGoodsInfo.objtype=="equip"||tempGoodsInfo.objtype=="material"){

                            _MGD.showGoodsUi(_MAP.node,
                                tempGoodsInfo,
                                {
                                    sence:_MG._CURRENTSENCE,
                                    pos:_MGD._POSGOODS,
                                    goodsIndex:realIndex,
                                    arr:goodsInfoArr
                                });

                        }else {
                            _TIPS.showMessage('此物品无法打造!',0);
                        }

                    }else if(_MG._CURRENTSENCE==_STYPE._DZSENCE){

                        if(tempGoodsInfo.objtype=="equip"){

                            _MDZ.setEquip(tempGoodsInfo);

                        }else{
                            _TIPS.showMessage('此物品无法锻造');
                        }

                    }else if(_MG._CURRENTSENCE==_STYPE._CJBSENCE){

                      if(tempGoodsInfo.objtype=="equip"){

                          _CJB.setEquip(tempGoodsInfo);

                      }else{
                        _TIPS.showMessage('此物品无法制作');
                      }

                  }
                }

            }, goodsbtn);
        }

    },

    getTotalPage:function(){
        var goodsArr = _MG.getCurrentGoodsInfoArr();
        if(!goodsArr||goodsArr.length<=0)
            return 0;
        if(goodsArr.length%_MG._PAGESIZE>0){
            return Math.floor(goodsArr.length/_MG._PAGESIZE)+1;
        }else{
            return goodsArr.length/_MG._PAGESIZE;
        }
        
    },

    turnPage:function(mainLabel,dir){

        var totalpage = _MG.getTotalPage();
        if(_MG._PAGE+dir<0){
            return;
        }else if(_MG._PAGE+dir>=totalpage){
            return;
        }
        _MG._PAGE = _MG._PAGE+dir;
        _MG.refreshPage(mainLabel);
    },

    initLeftNode:function(leftLabel){
        if(_MG._CURRENTSENCE==_STYPE._GOODSSENCE){//仓库
           _MG._LEFTNODE = _MRDL.initUi(
                leftLabel,
                {
                    sence:_MG._CURRENTSENCE,
                    roleArr:window.gameData.playerTeam,
                }
            );
        }else if(_MG._CURRENTSENCE==_STYPE._SHOPSENCE){//商店
            _MG._LEFTNODE = _MSHOP.showShop(leftLabel,_MG._CURRENTPARAM)
        }else if(_MG._CURRENTSENCE==_STYPE._INLAYSENCE){//镶嵌
            _MG._LEFTNODE = _MINLAY.showInlay(leftLabel,_MG._CURRENTPARAM)
        }else if(_MG._CURRENTSENCE==_STYPE._MAKESENCE){
            _MG._LEFTNODE = _MFORGIN.showForgin(leftLabel,null);
        }else if(_MG._CURRENTSENCE==_STYPE._DZSENCE){
            _MG._LEFTNODE = _MDZ.showDZ(leftLabel,null);
        }else if(_MG._CURRENTSENCE==_STYPE._CJBSENCE){
            _MG._LEFTNODE = _CJB.showCJB(leftLabel,null);
        }else if(_MG._CURRENTSENCE==_STYPE._XQSENCE){
            _MG._LEFTNODE = _MXQ.showXQ(leftLabel,null);;
        }
    },

    closeMG:function(){

        //刷新隐匿
        _MAP.refreshRoleInfo();

        if(_MG._LEFTNODE){
            _GRM.putNode(_MG._LEFTNODE);
            _MG._LEFTNODE=null;
        }
        _GRM.putNode(_MG._CURRENTLABEL);

    }

}